<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const list=[
            {
                id:1,
                name:'zs'
            },
            {
                id:2,
                name:'ls'
            },
            {
                id:3,
                name:'ww'
            }
        ];
        const id=3;
        // 根据条件查找数组索引
        const index=list.findIndex(function(item,index,arr){
            // console.log(item,index,arr);
            // 如果返回true, 就会将当前循环遍历项的索引返回
            return item.id===id;
        });
        console.log(index);
    </script>
</body>
</html>